﻿using System;
using System.Linq.Expressions;
using SBACN.WebSite.Code;
using SBACN.WebSite.Models;

namespace SBACN.WebSite
{
    public partial class MediaReport : BasePage
    {
        public int PageFlag { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            BindData(1);
        }


        protected void BindData(int pageIndex)
        {
            List.Visible = true;
            this.PageFlag = (pageIndex - 1) * this.Pager1.PageSize;
            int records = 0;
            Expression<Func<TB_Activities, bool>> f = (p => p.ID > 0);
            Expression<Func<TB_Activities, DateTime>> order = (c => c.ActivitiesDate);
            var resultQ = DAL.DALHelper.Instance.GetList<TB_Activities, DateTime>(f, order, false, this.Pager1.PageSize, pageIndex, out records);

            if (resultQ != null && resultQ.Count > 0)
            {

                this.List.DataSource = resultQ;
                this.List.DataBind();
                this.Pager1.RecordCount = records;
                this.Pager1.InitControl();
            }
            else
            {
                List.Visible = false;
            }
        }
        protected void BindSelectedPageIndexChanged(int pageIndex, int nextPage)
        {
            BindData(nextPage);
        }
    }
}